package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.SysMenuService;
import com.atguigu.spzx.model.entity.system.SysMenu;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

// com.atguigu.spzx.manager.controller
@RestController
@RequestMapping(value="/admin/system/sysMenu")
public class SysMenuController {
   
   @Autowired
   private SysMenuService sysMenuService;

   @PostMapping("/save")
   public Result save(@RequestBody SysMenu sysMenu) {
      sysMenuService.save(sysMenu);
      return Result.build(null , ResultCodeEnum.SUCCESS) ;
   }

   @DeleteMapping("/removeById/{id}")
   public Result removeById(@PathVariable Long id) {
      sysMenuService.removeById(id);
      return Result.build(null , ResultCodeEnum.SUCCESS) ;
   }

   @PutMapping("/updateById")
   public Result updateById(@RequestBody SysMenu sysMenu) {
      sysMenuService.updateById(sysMenu);
      return Result.build(null , ResultCodeEnum.SUCCESS) ;
   }

   @GetMapping("/findNodes")
   public Result findNodes() {
      List<SysMenu> list = sysMenuService.findNodes();
      return Result.build(list , ResultCodeEnum.SUCCESS) ;
   }

}